package com.sdy.healthcode.biz.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sdy.common.model.BizException;
import com.sdy.healthcode.biz.dto.*;
import com.sdy.healthcode.biz.dto.cockpit.CockpitAppointmentStatistic;
import com.sdy.healthcode.biz.dto.cockpit.CockpitExpertsAppointment;
import com.sdy.healthcode.biz.dto.holiday.HolidayYearDTO;
import com.sdy.healthcode.biz.model.ExpertsAppointment;
import com.sdy.mvc.service.BaseService;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 用户-专家预约表 服务类
 * </p>
 *
 * @author zzq
 * @since 2020-03-04
 */
public interface ExpertsAppointmentService extends BaseService<ExpertsAppointment> {

    /**
     * 获取某个时间段预约记录
     */
    List<ExpertsAppointment> listAppointmentByMap(Integer doctorId, Integer deptId, Date appointmentDateBegin, Date appointmentDateEnd);

    /**
     * 一周排班信息
     */
    List<ScheduleDTO> registerInfoOfDepartment(Integer deptId) throws BizException;

    /**
     * 查询某天排班信息
     *
     * @param dept
     * @param date eg. '2019-03-03'
     * @return
     */
    List<DoctorDTO> registerInfoOfDepartmentAndDay(Integer deptId, String date);

    /**
     * 专家预约信息详情
     *
     * @param doctorId
     * @param date     eg. '2019-03-03'
     * @return
     */
    DoctorDetailDTO expertScheduleDetail(Integer doctorId, String date);

    /**
     * 预约申请专家
     */
    Integer tryExpertAppointment(Integer userId, Integer expertsScheduleDailyId, Integer userPatientId) throws BizException;

    /**
     * 用户挂号信息(当天)
     */
    ExpertsAppointmentDTO getExpertInfo(Integer expertsAppointmentId) throws BizException;

    /**
     * 用户挂号信息
     */
    List<ExpertsAppointmentDTO> listExpertsAppointmentInfo(Integer userId, Integer state, Date date, Integer deptId);


    /**
     * 用户挂号信息-分页
     */
    IPage<ExpertsAppointmentDTO> pageExpertsAppointmentInfo(Page<ExpertsAppointmentDTO> page, Integer userId, Integer state, Date date);

    /**
     * 取消预约
     */
    void cancelApply(Integer userId, Integer expertsAppointmentId) throws BizException;

    /**
     * 预约人数统计
     */
    Integer countHospitalIn(String dateStr);

    /**
     * 用户取消预约次数
     */
    Integer countCancelApply(Integer userId);

    /**
     * 更新取消预约、节假日配置
     */
    void updateSettings(Integer expertsAppointmentBlackListCount,
                        Integer expertsAppointmentBlackListDays,
                        Boolean scheduleForHoliday,
                        HolidayYearDTO holidayConfig);

    /**
     * 预约挂号信息列表
     *
     * @param state
     * @param docState
     * @param name
     * @param startTime
     * @param endTime
     * @param page
     * @return
     * @throws BizException
     */
    IPage<GetAppointmentDTO> getAppointmentPageList(Integer state, Integer docState, String name, String startTime,
                                                    String endTime, Page page) throws BizException;

    /**
     * 预约挂号信息列表
     *
     * @param state
     * @param docState
     * @param name
     * @param startTime
     * @param endTime
     * @return
     * @throws BizException
     */
    List<GetAppointmentDTO> getAppointmentList(Integer state, Integer docState, String name, String startTime,
                                               String endTime) throws BizException;

    /**
     * 部门挂号情况
     */
    List<CockpitAppointmentStatistic> deptAppointmentMap();


    /**
     * 驾驶舱-取消预约分页
     */
    IPage<CockpitExpertsAppointment> pageExpertsAppointmentInfo(Page<CockpitExpertsAppointment> page, Integer state, Date date);
}
